package com.example.demo.config;

import lombok.Data;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletResponse;

/**
 * 响应类
 *
 * @author: yuy
 */
@Data
public class ResponseModel<T> {

    private int status;

    private String code;

    private String message;

    private T result;

    public ResponseModel() {
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder
            .getRequestAttributes()).getResponse();
        response.setCharacterEncoding("UTF-8");
    }

}
